<?php
namespace app\api\service;
use think\Controller;
use think\Db;

class Bank extends Controller {
    static protected $err_code = 0;

    // 获取提现页面数据
    static public function get_bank_info($param) {
        if(!isset($param['member_id']) || !isset($param['fund_account_id'])){
            return ['data'=>'','code'=>400001,'msg'=> 'FAULT'];
        }
        try {
            $member_fund_account = db('member_fund_account')->where('id', $param['fund_account_id'])->where('member_id', $param['member_id'])->find();
            return ['code' => 200, 'data' => $member_fund_account, 'msg' =>'success'];
        }catch (\Exception $e) {
            return ['code'=>self::$err_code, 'msg'=> $e->getMessage()];
        }
    }

    // 解除银行卡绑定
    static public function relieve_bank_band($param) {
        if(!isset($param['member_id']) || !isset($param['fund_account_id'])){
            return ['data'=>'','code'=>400001,'msg'=> 'FAULT'];
        }
        try {
            $rs = db('member_fund_account')->where('id', $param['fund_account_id'])->where('member_id', $param['member_id'])->update(['is_band'=> 0]);
            return ['code' => 200, 'data' => $rs, 'msg' =>'success'];
        }catch (\Exception $e) {
            return ['code'=>self::$err_code, 'msg'=> $e->getMessage()];
        }
    }
}
